package edu.kit.csl.cratyli.control;

import edu.kit.csl.cratyli.datatypes.Dictionary;

/**
 * A sentence target function defines the optimization criterium for a
 * combination strategy.
 */
public abstract class SentenceTargetFunction {

	/**
	 * Merges a primary and a secondary sentence to a new sentence.
	 * 
	 * @param dict dictionary
	 * @param prim primary sentence
	 * @param sec secondary sentence
	 * @return the merged sentence (blank separated)
	 */
	abstract public String merge(Dictionary dict, String[] prim, String[] sec);
	
	/**
	 * Converts a string array to a string (blank separated)
	 * 
	 * @param arr string array to convert
	 * @return array as blank separated string
	 */
	protected String arr2str(String[] arr) {
		StringBuilder newSen = new StringBuilder();
		for (String word : arr) { // Most granular path
			newSen.append(" " + word);
		}
		return newSen.toString().trim();
	}
}
